import http from "@/api";
import qs from "qs";

/**
 * @name 公共模块
 */

// 历史记录（请求、问题、变更、发布）
export const findAllHistoryRecordByClient = params => {
  return http.post(`/pages/clientRequest!findAllHistoryRecordByClient.action`, qs.stringify(params), { loading: false });
};

// 流程历史记录
export const findHistoryTask = params => {
  return http.post(`/pages/jbpm!findHistoryTask.action`, qs.stringify(params), { loading: false });
};

// 附件列表
export const findAllEventAttachment = params => {
  return http.post("/pages/eventAttachment!findAllEventAttachment.action", qs.stringify(params), { loading: false });
};

// 位置列表
export const getCategoryTreeAllData = params => {
  return http.post(`/pages/event!getCategoryTreeAllData.action`, qs.stringify(params), { loading: false });
};

// 上传
export const fileUpload = params => {
  return http.post("/pages/clientExecute!fileUpload.action", params, { loading: false });
};

// 上传2
export const uploadAttr = (tenanId, params) => {
  return http.post(`/pages/uploadFile!uploadAttr.action?tenantId=${tenanId}`, params, { loading: false });
};

// 保存附件
export const saveEventAttachment = params => {
  return http.post("/pages/eventAttachment!saveEventAttachment.action", qs.stringify(params), { loading: false });
};

// 历史邮件
export const findEmailAboutRequest = params => {
  return http.post("/pages/email!findEmailAboutRequest.action", qs.stringify(params), { loading: false });
};

// 所属客户列表
export const findMySupportITSOPUserPager = params => {
  return http.post(`/pages/clientRequest!findMySupportITSOPUserPager.action`, qs.stringify(params), { loading: false });
};

// 指派组
export const findAllClienk = params => {
  return http.post(`/pages/clientCompany!findAllClienk.action`, qs.stringify(params), { loading: false });
  // return http.get(`pages/organization!findAllNew.action`, {}, { cancel: false });
};

// 机构
export const findAllOrganization = params => {
  return http.post(`/pages/organization!findAll.action`, qs.stringify(params), { loading: false });
};

// 获取用户列表
export const findUserList = params => {
  return http.post(`/pages/user!find.action`, qs.stringify(params), { loading: false });
};

// (新增、编辑)获取扩展信息
export const attributeList = params => {
  return http.post(`/pages/ci!attributeList.action`, qs.stringify(params), { loading: false });
};

// 扩展信息(详情)
export const findAttributesByEavNo = params => {
  return http.post(`/pages/attrs!findAttributesByEavNo.action`, qs.stringify(params), { loading: false });
};

// 进展及成本
export const findPagerCost = (eno, eventType, params) => {
  return http.post(`/pages/cost!findPagerCost.action?costDTO.eno=${eno}&costDTO.eventType=${eventType}`, qs.stringify(params), {
    loading: false
  });
};

// 服务目录
export const getCategoryTree = params => {
  return http.post(`/pages/event!getCategoryTree.action`, qs.stringify(params), { loading: false });
};

// 配置项分类
export const getConfigurationCategoryTree = params => {
  return http.post(`/pages/ciCategory!getConfigurationCategoryTree.action`, qs.stringify(params), { loading: false });
};

// 新增进展与成本
export const saveCost = params => {
  return http.post(`/pages/cost!saveCost.action`, qs.stringify(params), { loading: false });
};

// 编辑进展与成本
export const editCost = params => {
  return http.post(`/pages/cost!editCost.action`, qs.stringify(params), { loading: false });
};

// 删除进展与成本
export const deleteCost = params => {
  return http.post(`/pages/cost!deleteCost.action`, qs.stringify(params), { loading: false });
};

// 流程图查看
export const getProcessImage = id => {
  return http.downloaditsm(`/pages/jbpm!getProcessImage.action?processDefinitionId=${id}`, qs.stringify({}), { loading: false });
};
//查看流程实例
export const getProcessInstance = params => {
  return http.post("/pages/jbpm!getActivityCoordinates.action?pid=" + params);
};
// 流程详情
export const processDetail = pid => {
  return http.post(`/pages/jbpm!processDetail.action?pid=${pid}`, qs.stringify({}), { loading: false });
};
